package com.rbtnet.ssc;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;

/**
 * 
 * @author 1136009436@qq.com
 *
 */
public class Test {
	
	public static void main(String[] args) {
		HttpClient client = HttpClients.createDefault();
    	String url = "http://774444.cc/json/ffc.json";
    	HttpGet getFfc = new HttpGet(url);
    	int one = 0;
    	int two = 0;
    	int three = 0;
    	int gua = 0;
    	int total = 0;
    	try {
			HttpResponse response = client.execute(getFfc);
			String entity = EntityUtils.toString(response.getEntity());
			String endList = JSON.parseObject(entity).get("EndList").toString();
			JSONArray endArry = JSON.parseArray(endList);
			total = endArry.size();
			for(int i=0;i<total;i++){
				String end = endArry.get(i).toString();
				if(end.contains("第1期")){
					one ++;
				}
				if(end.contains("第2期")){
					two ++;
				}
				if(end.contains("第3期") && end.contains("中")){
					three ++;
				}
				if(end.contains("第3期") && end.contains("挂")){
					gua ++;
				}
			}
			System.out.println("总共开奖："+total+"条记录");
			System.out.println("第1期中："+one+"把");
			System.out.println("第2期中："+two+"把");
			System.out.println("第3期中："+three+"把");
			System.out.println("挂："+gua+"把");
			System.out.println("-----------投注方案预测------------");
			System.out.println("单买第1期中："+(one-(total-one))+"把");
			System.out.println("单买第2期中："+(two-(three+gua))+"把");
			System.out.println("单买第3期中："+(three-gua)+"把");
			System.out.println("1期和2期都买中："+(one-three*2-gua*2)+"把");
			System.out.println("1期和3期都买中："+(one - two - gua*2)+"把");
			System.out.println("3期都买中："+(one - gua*3 - three)+"把");
    	} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
